(function() {
   jQuery.fn['bounds'] = function () {
     var bounds = {left: Number.POSITIVE_INFINITY, top: Number.POSITIVE_INFINITY,
                   right: Number.NEGATIVE_INFINITY, bottom: Number.NEGATIVE_INFINITY};

     this.each(function (i,el) {
                 var elQ = $(el);

                 if (elQ.length == 0)
                   return;

                 var off = elQ.offset();
                 off.right = off.left + $(elQ).width();
                 off.bottom = off.top + $(elQ).height();

                 if (off.left < bounds.left)
                   bounds.left = off.left;

                 if (off.top < bounds.top)
                   bounds.top = off.top;

                 if (off.right > bounds.right)
                   bounds.right = off.right;

                 if (off.bottom > bounds.bottom)
                   bounds.bottom = off.bottom;

               });
     bounds.width = bounds.right - bounds.left;
     bounds.height = bounds.bottom - bounds.top;
     return bounds;
   }
})();


function onBefore() { 
    $('#prodlabel').html(this.alt);
}

var tabs;

function stylishFormsCarnauba()
{
	$('select.stylish').sSelect({ ddMaxHeight: '200px' });
	
	$('.boxcenter input[type="checkbox"]').checkBox({addVisualElement: false});
	$('.boxcenter input[type="radio"]').checkBox({addVisualElement: false});
	
	//
	// START SCROLLBAR
    $("#scrollbar1").jCarouselLite({
        btnNext: "#scroll-down1",
        btnPrev: "#scroll-top1",
        vertical: true,
        mouseWheel: true,
        circular: false,
        speed:100,
        start:0,
        scroll:1
    });
    
    var scrolllistheight = $('#scrolllist').height();
    
    $('#scrolling1').slider({ 
    	orientation: 'vertical' ,
    	value:scrolllistheight,
    	distance: 0,
    	min:0,
    	max:scrolllistheight,
		slide: function(event, ui) {
    		var x = scrolllistheight-ui.value
			$("#scrollbar1 ul").css('top',-x);
		//	$("#temp").html(x);
		}
    });
    
    $("#scrollbar1").css('height','116px');
    $('#scroll-down1').css('cursor','pointer');
    $('#scroll-top1').css('cursor','pointer');
	// END SCROLLBAR
    //
    
    $('.sh').css('cursor','pointer');
}

$(document).ready(function(){
	
	tabs = function( elems ) {
		var heads = $( elems + ' .type1' );
		var tabsCont = $( '.tabs-cont' );
		heads.click(function(){
			
			if( $( this ).attr( 'class' ) != 'type1 focus' ) {
				heads.attr( 'class', 'type1' );
				$( this ).attr( 'class', 'type1 focus' );

				tabsCont.css( 'display', 'none' );
				$( tabsCont[$( this ).attr( 'tb' )] ).css( 'display', 'block' );
			}
			
		});
	};
	
	
	$('.sh, input[type="submit"]').css('cursor', 'pointer');
	
	$('#prodimages').cycle({ 
	    fx:     'scrollLeft', 
	    timeout: 0,
	    before:  onBefore,
	    speed:  300, 
	    next:   '#prodstright', 
	    prev:   '#prodstleft' 
	 });
	
	 stylishFormsCarnauba()
	
	
});